Fiy type can be missing on OnStats#962
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses the issue of handling cases where the "type" field may be missing on OnStats events. The changes update the stats event creation in the deebot client to use a safe retrieval method and add a corresponding test case.
- Updated test cases in tests/messages/json/test_stats.py to include a case with a missing "type" field.
- Modified deebot_client/messages/json/stats.py to use data.get("type") for safe handling of missing keys.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/messages/json/test_stats.py | Added a test case expecting a StatsEvent with type=None when missing. |
| deebot_client/messages/json/stats.py | Changed retrieval of the "type" field to use data.get("type") to allow for missing keys. |
Comments suppressed due to low confidence (1)
tests/messages/json/test_stats.py:113
- [nitpick] The key 'mowid' may be ambiguous; if intentional, consider adding a comment to clarify its purpose for maintainability.
{"mowid": "0", "time": 11269, "area": 2889500, "mowedArea": 1005475}
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## dev #962 +/- ##
=======================================
Coverage 93.60% 93.60%
=======================================
Files 128 128
Lines 4975 4975
Branches 324 324
=======================================
Hits 4657 4657
Misses 258 258
Partials 60 60 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #962 will not alter performanceComparing Summary
|
Fixes home-assistant/core#144643